<template>
  <view class="main">
	 <view class="part1">
	   <view class="part2">
		<view class="part2-1">订单评价</view> 
		<view class="part2-2">订单号：{{oinfo.ordersn}}</view> 
	   </view>
	  <view class="part3">
		  
		 <view class="part3-1">
		    <view class="p1">准时程度</view>
			<view class="p2">
               <view class="star" v-for="(item,index) in score" :class="[{'scur':item<=star1}]" @click="setstar1(item)"></view>
			</view>
		 </view> 
		<view class="part3-1">
		   <view class="p1">成片效果</view>
			<view class="p2">
              <view class="star" v-for="(item,index) in score" :class="[{'scur':item<=star2}]" @click="setstar2(item)"></view>
			</view>
		</view> 
			 
		 <view class="part3-1">
		    <view class="p1">服务态度</view>
			<view class="p2">
              <view class="star" v-for="(item,index) in score" :class="[{'scur':item<=star3}]" @click="setstar3(item)"></view>
			</view>
		 </view> 			 
			 
			 
		 
	  </view>		 
	 </view>  
	 <view class="part4">
		<view class="part4-1">
		<radio value="r1" :checked="r1==1" @click="setr()"/> 匿名评价
		</view>
		<textarea class="ptxt" placeholder="请输入评价内容" v-model="pcontent"></textarea>
		<view class="btn" @click="submitcontent()">确认提交</view>
	 </view>
  </view>
</template>

<script>
	import {
		mapGetters,
		mapActions
	} from 'vuex'
	import {
		toLogin
	} from '@/utils/login'
	
	import {
		loadingFun,
		menuJump
	} from '@/utils/tools'	
	import {
	   getOrderDetail,khpj
	} from '@/api/ppp'

	const app = getApp()
	export default {
		data() {
			return {
			 oid:0,
			 oinfo:[],
			 r1:0,
			 star1:0,
			 star2:0,
			 star3:0,
			 pcontent:"",
			 score:[1,2,3,4,5],
           }
		},
		onLoad(options) {
		 var oid=options.oid;
		 this.oid=oid;
		 this.getorderinfo(oid)
		},
		onShow() {

		},

		onReachBottom() {
	    
		},
		onPullDownRefresh() {

		},

	methods: {
	 async submitcontent(){
	 if(this.oinfo['pjflag1']==1){
	   uni.showToast({title:'您已经评价过了',icon:"none"})
	   return false;
	  }	 
	  if(this.oinfo['persion_pingjia']!=1){
	    uni.showToast({title:'无权限操作',icon:"none"})
	    return false;
	  }
	  if(this.pcontent==''){
		uni.showToast({title:'请填写评论',icon:"none"})
		return false;   
	  }
	  if(this.star1==0 || this.star2==0 || this.star3==0){
	  	uni.showToast({title:'请点击上方给拍手进行评分',icon:"none"})
	  	return false;   
	  }
	  const{code,msg,data
	  }= await khpj({oid:this.oid,r1:this.r1,star1:this.star1,star2:this.star2,star3:this.star3,pcontent:this.pcontent});
	  if(data.suc==1){
		uni.navigateTo({
		 url:"/pages/ppp/order/order1?oid="+this.oid	
		})  
	  }else{
		uni.showToast({title:data.msg,icon:"none"})
		return false;     
	  }
	 },
	  setstar1(score){this.star1=score;},
	  setstar2(score){this.star2=score;},
	  setstar3(score){this.star3=score;},
	  setr(){
		var r1=this.r1;
		if(r1==0){this.r1=1;return false;}
		if(r1==1){this.r1=0;return false;}
	  },
	  async getorderinfo(oid){
		const{
		code,
		msg,
		data
		}= await getOrderDetail(oid);
		this.oinfo=data; 
		if(data.pjflag1==1){
		  this.pcontent=data.pjinfo1.content;
		  this.star1=data.pjinfo1.star1;
		  this.star2=data.pjinfo1.star2;
		  this.star3=data.pjinfo1.star3;
		}
	  },  
	},
		computed: {
			...mapGetters(['isLogin']),
		}
	}
</script>
<style>
 @import "./pingjia.css";	
</style>
